# -*- encoding:utf-8 -*-
# @time: 2023/3/18 14:08
# @author: Maxs_hu
from django import forms
from django.forms import widgets
from django.core.validators import RegexValidator


class FM(forms.Form):
    role = forms.ChoiceField(
        label='角色',
        choices=((1, '管理员'), (2, '客户'),),
        widget=widgets.Select(attrs={'class': 'form-control'}),
    )
    username = forms.CharField(
        label='用户名',
        widget=widgets.TextInput(attrs={'class': 'form-control', 'placeholder': '用户名'}),
    )
    password = forms.CharField(
        label='密码',
        widget=widgets.PasswordInput(attrs={'class': 'form-control', 'placeholder': '密码'}),
        min_length=6
    )


class smsForm(forms.Form):
    role = forms.ChoiceField(
        label='角色',
        choices=((1, '管理员'), (2, '客户'),),
        widget=widgets.Select(attrs={'class': 'form-control'}),
    )
    mobile = forms.CharField(
        label='电话号码',
        widget=widgets.TextInput(attrs={'class': 'form-control', 'placeholder': '电话号码'}),
        validators=[RegexValidator(r'^1[35789]\d{9}$', '手机格式错误'), ]  # 验证

    )
    code = forms.CharField(
        label='验证码',
        widget=widgets.PasswordInput(attrs={'class': 'form-control', 'placeholder': '验证码'}),
        min_length=6
    )


class verifyForm(forms.Form):
    role = forms.ChoiceField(
        label='角色',
        choices=((1, '管理员'), (2, '客户'),),
        widget=widgets.Select(attrs={'class': 'form-control'}),
    )
    mobile = forms.CharField(
        label="手机号",
        required=True,
        validators=[RegexValidator(r'^1[35789]\d{9}$', '手机格式错误'), ]  # 验证
    )

    def clean_mobile(self):
        pass
